package com.fuqi.android.zhongcai.base.view.activity.deprecated;


import android.view.KeyEvent;
import android.view.View;
import android.widget.TextView;

import com.fuqi.android.zhongcai.R;
import com.fuqi.android.zhongcai.base.model.ProvinceList;
import com.fuqi.android.zhongcai.base.view.activity.BaseActivity;
import com.fuqi.android.zhongcai.base.view.widget.wheelwidget.OptionsPickerView;
import com.fuqi.android.zhongcai.utils.ActivityUtils;
import com.fuqi.android.zhongcai.utils.LogUtils;
import java.util.ArrayList;

import butterknife.Bind;
import butterknife.OnClick;

@Deprecated
public class ShuiGuanActivity extends BaseActivity {

    @Bind(R.id.tv_wei_count)
    TextView tvWeiCount;
    @Bind(R.id.tv_chu_count)
    TextView tvChuCount;
    @Bind(R.id.tv_yangtai_count)
    TextView tvYangTaiCount;
    @Bind(R.id.tv_anzhuang_content)
    TextView tvInstallContent;
    @Bind(R.id.tv_anzhuang_date)
    TextView tvInstallDate;
    @Bind(R.id.tv_ppr)
    TextView tvPPR;
    @Bind(R.id.tv_pay_way)
    TextView tvPayWay;
    @Bind(R.id.tv_diqu)
    TextView tvAdress;

    private ArrayList<String> options1Items = new ArrayList<>();
    OptionsPickerView pvOptions;

    final int TYPE_SELECT_CHU = 0;
    final int TYPE_SELECT_WEI = 1;
    final int TYPE_SELECT_YANG_TAI = 2;
    final int TYPE_SELECT_INSTALL_CONTENT = 3;
    final int TYPE_SELECT_INSTALL_DATE = 4;
    final int TYPE_SELECT_PPR = 5;
    final int TYPE_SELECT_PAY_WAY = 6;


    @OnClick({R.id.btn_submit,R.id.tv_diqu,R.id.rl_address,R.id.tv_wei_count,R.id.tv_chu_count,R.id.tv_yangtai_count,R.id.tv_anzhuang_content,R.id.rl_anzhuang_content,R.id.tv_ppr,R.id.rl_ppr,R.id.tv_pay_way,R.id.rl_pay_way})
    public void onClick(View view){

        switch(view.getId()){

            case R.id.btn_submit:

                ActivityUtils.startActivity(ShuiGuanActivity.this,MakeOrderDetailActivity.class);

                break;
            case R.id.tv_wei_count:

                selectByWheelWidget(TYPE_SELECT_WEI);

                break;
            case R.id.tv_chu_count:

                selectByWheelWidget(TYPE_SELECT_CHU);

                break;
            case R.id.tv_yangtai_count:

                selectByWheelWidget(TYPE_SELECT_YANG_TAI);

                break;
            case R.id.tv_anzhuang_content:
            case R.id.rl_anzhuang_content:

                selectByWheelWidget(TYPE_SELECT_INSTALL_CONTENT);

                break;

            case R.id.tv_ppr:
            case R.id.rl_ppr:
                selectByWheelWidget(TYPE_SELECT_PPR);

                break;

            case R.id.tv_pay_way:
            case R.id.rl_pay_way:
                selectByWheelWidget(TYPE_SELECT_PAY_WAY);

                break;

            case R.id.tv_diqu:
            case R.id.rl_address:


                pvOptions.setPicker(ProvinceList.getOptions1Items(), ProvinceList.getOptions2Items(), ProvinceList.getOptions3Items(), true);
                pvOptions.setCyclic(false, true, true);
                pvOptions.setSelectOptions(1, 1, 1);
                pvOptions.setOnoptionsSelectListener(new OptionsPickerView.OnOptionsSelectListener() {

                    @Override
                    public void onOptionsSelect(int options1, int option2, int options3) {
                        //返回的分别是三个级别的选中位置
                        String tx = ProvinceList.getOptions1Items().get(options1).getPickerViewText()
                                + ProvinceList.getOptions2Items().get(options1).get(option2)
                                + ProvinceList.getOptions3Items().get(options1).get(option2).get(options3).getPickerViewText();
                        tvAdress.setText(tx);
                    }
                });
                pvOptions.show();


                break;

        }


    }


    private void selectByWheelWidget(final int selectType){



        switch (selectType){

            case TYPE_SELECT_CHU:
            case TYPE_SELECT_WEI:
            case TYPE_SELECT_YANG_TAI:
                options1Items.clear();
                options1Items.add("一");
                options1Items.add("二");
                options1Items.add("三");
                options1Items.add("四");
                options1Items.add("五");
                options1Items.add("六");
                options1Items.add("七");
                break;

            case TYPE_SELECT_INSTALL_CONTENT:



                options1Items.clear();
                options1Items.add("安装");
                options1Items.add("改装");
                options1Items.add("加装");
                options1Items.add("返工");
                options1Items.add("检修");
                options1Items.add("空跑");

                break;

            case TYPE_SELECT_PPR:

                options1Items.clear();
                options1Items.add("黄金系列");
                options1Items.add("铂金系列");
                options1Items.add("绿钻系列");
                options1Items.add("5A系列");
                options1Items.add("纳米高菌系列");
                options1Items.add("红钻系列");

                break;

            case TYPE_SELECT_PAY_WAY:

                options1Items.clear();
                options1Items.add("现场收取");
                options1Items.add("代收");
                options1Items.add("月结");

                break;
        }

        pvOptions.setPicker(options1Items);

        pvOptions.show();
        pvOptions.setSelectOptions(1, 0, 0);
        pvOptions.setOnoptionsSelectListener(new OptionsPickerView.OnOptionsSelectListener() {

            @Override
            public void onOptionsSelect(int options1, int option2, int options3) {
                if(options1Items.size() <= options1)       return ;
                switch (selectType){

                    case TYPE_SELECT_CHU:
                        tvChuCount.setText(options1Items.get(options1).toString());
                        break;
                    case TYPE_SELECT_WEI:
                        tvWeiCount.setText(options1Items.get(options1).toString());
                        break;
                    case TYPE_SELECT_YANG_TAI:
                        tvYangTaiCount.setText(options1Items.get(options1).toString());
                        break;

                    case TYPE_SELECT_INSTALL_CONTENT:
                        tvInstallContent.setText(options1Items.get(options1).toString());
                        break;

                    case TYPE_SELECT_PPR:
                        tvPPR.setText(options1Items.get(options1).toString());
                        break;

                    case TYPE_SELECT_PAY_WAY:
                        tvPayWay.setText(options1Items.get(options1).toString());
                        break;
                }


                //ActivityUtils.toast("options1: " + options1);
                LogUtils.i("juner select position: " + options1);

            }
        });

    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            if(pvOptions.isShowing()){
                pvOptions.dismiss();
                return true;
            }

        }
        return super.onKeyDown(keyCode, event);
    }

    @Override
    public void initView() {

        pvOptions = new OptionsPickerView(this);

    }

    @Override
    public void initListener() {





    }

    @Override
    public void initData() {
        titleBar.setTitle("立即下单");
    }

    @Override
    public boolean hasTitleBar() {
        return true;
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_zhuang_shui_guan;
    }
}
